
import 'dart:convert';
import 'package:ichinesereader/models/class/ClassResp.dart';

List<ClassAnnouncement> classAnnouncementFromJson(String str) =>
    List<ClassAnnouncement>.from(
        json.decode(str).map((x) => ClassAnnouncement.fromJson(x)));

String classAnnouncementToJson(List<ClassAnnouncement> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class ClassAnnouncement {
  ClassAnnouncement({
    this.id,
    this.message,
    this.point,
    this.allStudentsClass,
    this.when,
    this.classResp,
    this.teacherName,
    this.teacherUsername,
  });

  String? id;
  String? message;
  int? point;
  bool? allStudentsClass;
  int? when;
  ClassResp? classResp;
  String? teacherName;
  String? teacherUsername;

  factory ClassAnnouncement.fromJson(Map<String, dynamic> json) =>
      ClassAnnouncement(
        id: json["id"],
        message: json["message"],
        point: json["point"],
        allStudentsClass: json["allStudentsClass"],
        when: json["when"],
        classResp: ClassResp.fromJson(json["classResp"]),
        teacherName: json["teacherName"],
        teacherUsername: json["teacherUsername"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "message": message,
        "point": point,
        "allStudentsClass": allStudentsClass,
        "when": when,
        "classResp": classResp?.toJson(),
        "teacherName": teacherName,
        "teacherUsername": teacherUsername,
      };
}
